import Decimal from 'decimal.js'
import { InferAttributes } from 'sequelize'
import { Column, DataType, Model, PrimaryKey, Table } from 'sequelize-typescript'

@Table({ tableName: 'dealer', underscored: true, timestamps: false })
export class Dealer extends Model<InferAttributes<Dealer>> {
    @PrimaryKey
    @Column
    declare id: number

    @Column
    declare is_del: number

    @Column
    declare enable: number

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('price') ?? 0)
        },
    })
    declare price: Decimal

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('a_balance_pool') ?? 0)
        },
    })
    declare a_balance_pool: Decimal

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('b_balance_pool') ?? 0)
        },
    })
    declare b_balance_pool: Decimal

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('c_balance_pool') ?? 0)
        },
    })
    declare c_balance_pool: Decimal

    @Column({
        type: DataType.DECIMAL,
        get() {
            return new Decimal(this.getDataValue('d_balance_pool') ?? 0)
        },
    })
    declare d_balance_pool: Decimal
}
